#! /bin/bash

build_path="/mnt/code/anyos/build"
cortexa_envpath="/opt/fsl-imx-x11/4.1.15-2.1.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi"
if [ $1 == "clean" ]; then
	echo "clean build path"
	rm -rf $build_path
elif [ $1 == "cortexa" ]; then
	if [ ! -d $build_path ]; then
		mkdir $build_path
	fi

	cd $build_path
	source $cortexa_envpath
	cmake ..
	make
elif [ $1 == "cortexnew" ]; then
	if [ ! -d $build_path ]; then
		mkdir $build_path
	fi

	cd $build_path
	cmake -DCMAKE_TOOLCHAIN_FILE=linux-armhf.cmake ..
	make
elif [ $1 == "stm32" ]; then
	if [ ! -d $build_path ]; then
		mkdir $build_path
	fi

    export PATH=$PATH:/opt/gcc-arm-none-eabi-9-2020-q2-update/bin
	cd $build_path
	cmake -DSTM32=1 -DCMAKE_TOOLCHAIN_FILE=linux-stm32.cmake ..
	make
else
	echo "invalid option."
fi
